using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using LeisureCenter.Core;

namespace LeisureCenter.Forms
{
    public partial class ExceptionHandlerForm : Form
    {
        private ExceptionInfo exceptionInfo;
 
        public ExceptionHandlerForm(ExceptionInfo exceptionInfo)
        {
            InitializeComponent();
            this.exceptionInfo = exceptionInfo;
            tbMessage.Text = exceptionInfo.Message;
        }

        private void btnContinue_Click(object sender, EventArgs e)
        {
            CloseWithResult(DialogResult.OK);
        }
        
        private void btnExit_Click(object sender, EventArgs e)
        {
            CloseWithResult(DialogResult.Abort);
        }

        private void btnRestart_Click(object sender, EventArgs e)
        {
            CloseWithResult(DialogResult.Retry);
        }

        private void CloseWithResult(DialogResult result)
        {
            tbMessage.Hide();
            if (btnSendReport.Down)
            {
                pnlButtons.Enabled = false;
                ExceptionHandler.SendMailForException(this.exceptionInfo);
            }
            DialogResult = result;
        }

        private void tbMessage_Enter(object sender, EventArgs e)
        {
            tbMessage.ForeColor = SystemColors.WindowText;
        }

        private void btnSendReport_Click(object sender, EventArgs e)
        {
            btnSendReport.Down = !btnSendReport.Down;
        }

    }
}